package cn.net.zj.scan.utils;

import android.content.Context;
import android.os.Handler;

import com.maning.mndialoglibrary.MProgressDialog;
import com.maning.mndialoglibrary.MStatusDialog;

import cn.net.zj.scan.R;


public class MProgressDialogHelper {

    public interface MProgressDialogHelperListener {
        void complete();
    }

    public static void showLoading(Context context) {
        MProgressDialog.showProgress(context);
    }

    public static void showSuccess(Context context, String msg, final MProgressDialogHelperListener listener) {
        if (context == null) {
            return;
        }
        new MStatusDialog(context).show(msg, context.getResources().getDrawable(R.drawable.mn_icon_dialog_ok));
        if (listener != null) {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    listener.complete();
                }
            }, 2500L);
        }
    }

    public static void showFail(Context context, String msg, final MProgressDialogHelperListener listener) {
        if (context == null) {
            return;
        }
        new MStatusDialog(context).show(msg, context.getResources().getDrawable(R.drawable.delete));
        if (listener != null) {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    listener.complete();
                }
            }, 2500L);

        }
    }
}
